package org.person.gift.strategy;

import cn.ronghuanet.gift.exception.BusinessException;
import cn.ronghuanet.gift.exception.ResponseCode;
import cn.ronghuanet.gift.exception.RonghuaAssert;

public class SplitOrderStrategyFactory {

    public static SplitOrderStrategy getStrategy(String clazz){
        RonghuaAssert.isNotBlank(clazz, ResponseCode.RESPONSE_CODE_500);
        try {
            Class<?> aClass = Class.forName(clazz);
            Object obj = aClass.newInstance();
            if(obj instanceof SplitOrderStrategy){
                return (SplitOrderStrategy)obj;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        throw new BusinessException(ResponseCode.RESPONSE_CODE_500);
    }

}
